package com.yvdelx.cyclowomen.connector;

import org.simpleframework.xml.transform.Transform;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Custom Date Format Transformer for Persister usage in XmlWriter.class
 * Created by ydelvaux on 04/03/2015.
 */
public class CustomDateFormatTransformer implements Transform<Date> {

    private static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

    @Override
    public Date read(String value) throws Exception {
        return df.parse(value);
    }

    @Override
    public String write(Date value) throws Exception {
        return df.format(value);
    }
}